<?php
include_once("../includes/page_utf_class.php");
include_once("../config/usergroup.php");
//====================================
if(!empty($_POST['de'])&&empty($_POST['passall']))
{
	del_user($_POST['de']);
}
function del_user($ar)
{
	global $db,$config;
	foreach($ar as $v)
	{	
		$userid=$v;
		ext_all('delete_by_uid',array('uid'=>$userid));
		$db->query("delete from ".ALLUSER." where userid='$userid'");
		$db->query("delete from ".FEED." where userid='$userid'");
		$db->query("delete from ".FEEDBACK." where touserid='$userid' or fromuserid='$userid'");
		$db->query("delete from ".ACCOUNTS." where userid='$userid'");
		$db->query("delete from ".CASHFLOW." where userid='$userid'");
		$db->query("delete from ".CASHPICKUP." where userid='$userid'");
        $db->query("delete from ".COMMENT." where fromuid='$userid'");
		$db->query("delete from ".FAVORITE." where userid='$userid'");
		$db->query("delete from ".READREC." where userid='$userid'");
		$db->query("delete from ".SUBSCRIBE." where userid='$userid'");
		$db->query("delete from ".EAR." where userid='$userid'");
	}
}

$categorys['company']=lang_show('company_name');
$categorys['user']=lang_show('user_id');
$categorys['contact']=lang_show('contact');
$categorys['tel']=lang_show('company_tel');

@include_once('config/module_company_config.php');
$companyType=explode('|',$module_company_config['companyType']);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="main.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="main.js"></script>
<title><?php echo lang_show('admin_system');?></title>
</head>
<body>

<div class="bigbox">
	<div class="bigboxhead"><?php echo lang_show('query');?></div>
	<div class="bigboxbody">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<form name="frmuser" method="get" action="">
	<?php if($module_company_config['identity']){?>
	<tr> 
		  <td width="10%" height="22">会员身份</td>
		  <td width="90%">
		  <select class="select" name="identity">
			<option value=""><?php echo lang_show('all_company_type');?></option>
			<?php
			$identity=explode('|',$module_company_config['identity']);
			foreach($identity as $key=>$v)
			{
			?>
			<option value="<?php echo $key;?>" <?php if($v==$_GET['identity']) echo "selected"; ?>><?php echo $v?></option>
			<?php
			}
			?>
		  </select>
		  </td>
	</tr>
	<?php } ?>
  <tr>
      <td width="10%" height="22"><?php echo lang_show('belong_industry');?></td>
      <td width="90%"><select class="select" name="catid" >
        <option value="0" style='font-weight:bold; font-size:14px;'><?php echo lang_show('all_industry');?></option>
        <?php
				$slectid=isset($_GET["catid"])?$_GET["catid"]:'';
				$db->query("select catid,cat from  ".COMPANYCAT."  where catid<=9999 order by nums asc");
				$catList=$db->getRows();
				foreach($catList as $v)
				{
					if($v['catid']==$slectid)
						echo "<option style='color:red;font-weight:bold;padding-left:20px;' value=".$v['catid']." selected=selected >|_".$v['cat']."</option>";
					else
						echo "<option style='color:red;font-weight:bold;padding-left:20px;' value=".$v['catid']." >|_".$v['cat']."</option>";
					$s=$v['catid'].'00';
					$b=$v['catid'].'99';
					$sql="select catid,cat from  ".COMPANYCAT."  where catid<=$b and catid>=$s order by nums asc";
					$db->query($sql);
					$scat=$db->getRows();
					foreach($scat as $sv)
					{
						if($sv['catid']==$slectid)
							echo "<option style='font-weight:bold;padding-left:40px;' value=".$sv['catid']." selected=selected >|____".$sv['cat']."</option>";
						else
							echo "<option style='font-weight:bold;padding-left:40px;' value=".$sv['catid']." >|____".$sv['cat']."</option>";
						$s=$sv['catid'].'00';
						$b=$sv['catid'].'99';
						$sql="select catid,cat from  ".COMPANYCAT."  where catid<=$b and catid>=$s order by nums asc";
						$db->query($sql);
						$tcat=$db->getRows();
						foreach($tcat as $tv)
						{
							if($tv['catid']==$slectid)
								echo "<option style='padding-left:60px;' value=".$tv['catid']." selected=selected >|________".$tv['cat']."</option>";
							else
								echo "<option style='padding-left:60px;' value=".$tv['catid']." >|________".$tv['cat']."</option>";
						}

					}
				}
				?>
      </select></td>
  </tr>
  
	<tr>
      <td width="10%" height="22"> 
        <?php echo lang_show('member_type');?></td>
      <td width="90%"><select class="select" name="only" id="only">
        <option value="" selected><?php echo lang_show('all_member');?></option>
        <?php
            $sql="select * from ".USERGROUP." order by group_id asc";
            $db->query($sql);
            $re=$db->getRows();
            foreach($re as $v)
	          {
           ?>
        <option value="<?php echo $v['group_id']; ?>" <?php if($_GET['only']==$v['group_id']) echo "selected"; ?>><?php echo $v['name']; ?></option>
        <?php
              }
           ?>
      </select>
	  </td>
	</tr>
	<tr>
      <td width="10%" height="22">显示方式</td>
      <td width="90%">
	  <select class="select" name="ordrby">
        <option <?php if ($_GET['ordrby']=='uptime') echo "selected";?> value="uptime">按更新时间</option>
        <option <?php if ($_GET['ordrby']=='rank') echo "selected";?> value="rank">按排名</option>
        <option <?php if ($_GET['ordrby']=='tj') echo "selected";?> value="tj">按推荐</option>
      </select>
	  <input type="radio" name="order" value="" <?php echo $_GET['order']==""?"checked":""?> />
		<?php echo lang_show('desc');?>
		<input type="radio" name="order" value="desc" <?php echo $_GET['order']=="desc"?"checked":""?> />
		<?php echo lang_show('asc');?> 
		
      </td>
	</tr>
  	<tr>
  	  <td height="22"><?php echo lang_show('bylastlogotime');?></td>
	  <td>
	  	 <select class="select" name="lastlogotime" id="lastlogotime">
          <option value=""><?php echo lang_show('alllogotime');?></option>
          <option value="1" <?php if (!empty($_GET['lastlogotime'])&&$_GET['lastlogotime']=='1') echo "selected";?>><?php echo lang_show('oneh');?></option>
          <option value="2" <?php if (!empty($_GET['lastlogotime'])&&$_GET['lastlogotime']=='2') echo "selected";?>><?php echo lang_show('twoh');?></option>
          <option value="12" <?php if (!empty($_GET['lastlogotime'])&&$_GET['lastlogotime']=='12') echo "selected";?>><?php echo lang_show('halfd');?></option>
          <option value="24" <?php if (!empty($_GET['lastlogotime'])&&$_GET['lastlogotime']=='24') echo "selected";?>><?php echo lang_show('oneday');?></option>
  	      <option value="48" <?php if (!empty($_GET['lastlogotime'])&&$_GET['lastlogotime']=='48') echo "selected";?>><?php echo lang_show('twoday');?></option>
  	      <option value="72" <?php if (!empty($_GET['lastlogotime'])&&$_GET['lastlogotime']=='72') echo "selected";?>><?php echo lang_show('threeday');?></option>
  	      <option value="168" <?php if (!empty($_GET['lastlogotime'])&&$_GET['lastlogotime']=='168') echo "selected";?>><?php echo lang_show('oneweek');?></option>
  	      <option value="336" <?php if (!empty($_GET['lastlogotime'])&&$_GET['lastlogotime']=='336') echo "selected";?>><?php echo lang_show('twoweek');?></option>
  	      <option value="720" <?php if (!empty($_GET['lastlogotime'])&&$_GET['lastlogotime']=='720') echo "selected";?>><?php echo lang_show('onemonth');?></option>
	      </select>
		  </td>
	  </tr>
  	<tr>
  	  <td height="22">关键词</td>
	  <td><select class="lselect" name="category">
        <?php foreach($categorys as $keys=>$v){ ?>
        <option value="<?php echo $keys;?>" <?php if($_GET['category']==$keys ) echo "selected";?> ><?php echo $v; ?></option>
        <?php } ?>
      </select> -- 
        <input class="rtext" name="keyword" type="text" value="<?php echo $_GET['keyword'];?>" size="40" /></td>
  	</tr>
	  	<tr>
  	  <td height="22">过滤条件</td>
  	  <td>
		<input type='checkbox' <?php echo $_GET['is_tel']=="1"?"checked":""?> name='is_tel' value='1' />电话
		</td>
	  </tr>
  	<tr>
      <td height="22">&nbsp;</td>
      <td><input class="btn" type="submit" name="Submit" value="<?php echo lang_show('search');?>" />
	  <input name="m" type="hidden" value="company" />
	  <input name="s" type="hidden" value="company.php" />
	  </td>
  	</tr>
</form>
</table>
  </div>
</div>
<div style="float:left; height:20px; width:80%;">&nbsp;</div>
<?php if(isset($_GET['Submit'])){ ?>
<form method="post">
<div class="bigbox">
	<div class="bigboxhead"><?php echo lang_show('member_list');?></div>
	<div class="bigboxbody">
<table width="100%" border="0" cellspacing="0" cellpadding="1" align="center" class="menu">
  <tr class="theader"> 
  	<td width="26"  align="center" >
  <input name="checkbox" type="checkbox" onClick="do_select()" value="checkbox"></td>
    <td width="54" align="left" ><?php echo lang_show('member_id');?></td>
    <td width="241" align="left" ><?php echo lang_show('company_name');?></td>
    <td width="66" align="left" >保证金</td>
    <td width="80" align="left" >企业类型</td>
    <td width="123" align="left" >有效期</td>
    <td width="102" align="left" ><?php echo lang_show('rank');?></td>
    <td width="71" align="left" >被访次数</td>
    <td width="69" align="left" >更新时间</td>
    <td width="98" align="center" ><?php echo lang_show('manager');?></td>
  </tr>
  <?php
  	unset($_GET['userid']);unset($_GET['s']);
  	$getstr=implode('&',convert($_GET));
  	
	if(!empty($_GET['ordrby']))
		$ordrby='u.'.$_GET['ordrby'];
	else
		$ordrby='u.uptime';
		
	if(!empty($_GET['keyword']))
		$scl.=" and (u.$_GET[category] regexp '$_GET[keyword]')  ";
	if(!empty($_GET['only']))
		$scl.=" and u.ifpay='".$_GET['only']."'";
	if($_SESSION['province'])
		$scl.=" and u.province='$_SESSION[province]'";
	if($_SESSION['city'])
		$scl.=" and u.city='$_SESSION[city]'";
	if(!empty($_GET['catid']))
		$scl.=" and u.catid like '%,$_GET[catid]%'";
	if(!empty($_GET['identity']))
		$scl.=" and u.identity='$_GET[identity]'";
	if(!empty($_GET['is_tel']))
		$scl.=" and u.tel!='' ";
//==================================
	$sql="SELECT * from ".USER." u  WHERE 1 $scl";
	if($_GET['order']) 
	   $sql.=" order by $ordrby asc";  
	else 
	   $sql.=" order by $ordrby desc ";
	//=============================
	$page = new Page;
	$page->listRows=100;
	if (!$page->__get('totalRows')){
		$db->query($sql);
		$page->totalRows = $db->num_rows();
	}
	$sql .= "  limit ".$page->firstRow.",100";
	$pages = $page->prompt();
	//=====================
	$db->query($sql);
	$i=0;
	foreach($db->getRows() as $v)
	{
		$ifpay=$v['ifpay'];
		if(!empty($group[$ifpay]['minilogo'])&&$ifpay!=1)
			$ifpay="<img src='".$group[$ifpay]['minilogo']."' alt='".$group[$ifpay]['name']."' >";
		else
			$ifpay=NULL;
?> 
  <tr onMouseOver="mouseOver(this)" onMouseOut="mouseOut(this,'odd')"> 
    <td width="26" align="center"><input name="de[]" type="checkbox" id="de<?php echo $i++?>" value="<?php echo !empty($v['userid'])?$v['userid']:$v['buid']; ?>"></td>
	<td width="54" align="left"><?php echo $v['user'];?></td>
    <td align="left">
	<?php if($v['tj']>0) echo '<img src="../image/default/'.$v['tj'].'.jpg">'; ?>
	<a href="<?php echo $config['weburl']; ?>/shop.php?uid=<?php echo !empty($v['userid'])?$v['userid']:$v['buid']; ?>" target="_blank">
	<?php echo $ifpay.htmlspecialchars($v['company']); ?></a>
	<br>
      <?php echo $v['contact']; if(!empty($v['tel'])){ echo '&nbsp;'.lang_show('tel').':'. $v['tel']; }?>	  </td>
		<td align="left"><?php echo $v['earnest'];?></td>
		<td align="left"><?php echo $v['ctype'];?></td>
		<td align="left">
		<?php 
			if($v['etime'])
			{
				if($v['etime']-time()<=3600*24*7&&$v['etime']>0)
					echo "<font color='red'>*</font>";
			}
			echo date("Y-m-d",$v['stime']).'/'.date("Y-m-d",$v['etime']);
		?>
		</td>
		<td align="left"><?php echo $v['rank']; ?></td>
		<td align="left"><?php echo $v['view_times']; ?></td>
		<td align="left"><?php echo date("Y-m-d",$v['uptime']); ?></td>
		<td align="center">
		<a title="<?php echo lang_show('send_mail');?>" href="sendmail.php?userid=<?php echo !empty($v['userid'])?$v['userid']:$v['buid']; ?>"><?php echo $mailimg;?></a>
		<a href="module.php?m=company&s=company_edit.php&userid=<?php echo $v['userid'].'&'.$getstr; ?>"><?php echo $editimg;?></a>
		<a title="<?php echo lang_show('enteroffice');?>" href="to_login.php?action=submit&user=<?php echo $v['user']; ?>" target="_blank"><?php echo $setimg;?></a>
		</td>
  </tr>
	<?php
	}
	?> 
</table>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="45%" height="24"><input class="btn" type="submit" name="Submit2" value="<?php echo lang_show('delete');?>" onClick='return confirm("<?php echo lang_show('are_you_sure');?>");'></td>
    <td width="65%" align="right"><div class="page"><?php echo $pages?></div></td>
  </tr>
</table>
	</div>
</div>

</form>
<?php } ?>
</body>
</html>